<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Person{
            //构造器函数，实例化对象会调用原型对象上的constructor方法
            constructor(name,age){
                this.name = name ;
                this.age =age;
            }
            
            //实例化对象上的属性，如果不传参可以不写在constructor里面
            run = 'run'

            // 也是给实例化对象添加方法
            do = function(){
                console.log('do');
            }

            //给原型对象扩展方法
            eat = function(){
                console.dir('eat');
            }

            //静态属性
            static say = 'hello react'
        }   
        console.dir(Person);

    //    ES6
        class Student extends Person{
            //只要子类书写constructor，必须在constructor中调用super
            //因为子类没有自己的this，需要调用super来构建自己的this
            constructor (name,age,score){
                // super的参数是传给父类的constructor
                super(name,age)
                this.score = score;
            }
            study = 'react';

            run(){
                console.log('运动');
            }
        }
    </script>
</body>
</html>